Skip to content

Conversation

@drempapis
Copy link
Contributor

@drempapis drempapis commented May 6, 2025

This work presents an approach for tracking search load per index in a multi-project Elasticsearch environment, with the goal of dynamically adjusting replica counts to optimize resource utilization and maintain a balance between under- and overutilization.

The implementation integrates ShardSearchLoadRateService into IndexShard as an SPI extension point, enabling flexible extension of shard-level search load tracking.

Additionally, it introduces the SearchStatsSettings class, which enables half-life calculations within StatelessShardSearchLoadRateService::ExponentiallyWeightedMovingRate, and facilitates scheduled, pull-based collection of search node metrics in serverless deployments.

@drempapis drempapis added the :Search Foundations/Search Catch all for Search Foundations label May 6, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@elasticsearchmachine elasticsearchmachine added the serverless-linked Added by automation, don't add manually label May 21, 2025
Copy link
Member

@piergm piergm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, I wonder if we should ask for another pair of eyes on this before merging. Otherwise you can merge it as long as the CI is happy :D

@drempapis
Copy link
Contributor Author

This LGTM, I wonder if we should ask for another pair of eyes on this before merging. Otherwise you can merge it as long as the CI is happy :D

Definitely, thank you, Matteo for the review!

@andreidan andreidan self-requested a review May 27, 2025 08:47
Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this Dimi.

I have some initial questions regarding the overall design.
Also, please update the PR description to contain more details around the what and the why for this effort.

CollectionUtils.appendToCopyNoNullElements(listeners, internalIndexingStats, indexingFailuresDebugListener),
logger
);
this.shardSearchLoadRateService = shardSearchLoadRateProvider.create(searchStatsSettings, System::currentTimeMillis);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we're injecting a service here. Could the index shard calculate the ewmr directly?
What's the reason for the SPI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. The main reason for injecting the service via SPI rather than calculating the EWMR directly in IndexShard is to avoid unnecessary memory overhead when the functionality isn't needed. While lazy initialization behind a proxy is an option on the stateful side, it would add unnecessary complexity to the core codebase.

Additionally, this design helps separate concerns: the implementation is specific to the multi-project setup and doesn't belong in the core logic of IndexShard. Placing it behind an SPI keeps the core codebase clean and aligns the implementation more closely with the project that owns the logic, improving maintainability and modularity. So, keeping it behind an SPI ensures it's only enabled where applicable.

@drempapis
Copy link
Contributor Author

This pr has been closed in favor of #128660

@drempapis drempapis closed this Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Search Foundations/Search Catch all for Search Foundations serverless-linked Added by automation, don't add manually Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants